#include "cbase.h"
#include "hl2mp/hl2mp_gamerules.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

class CRestartRoundEntity: public CLogicalEntity
{
public:
	DECLARE_CLASS( CRestartRoundEntity, CLogicalEntity );

	void InputRestart( inputdata_t &inputdata );

private:

	DECLARE_DATADESC();
};

LINK_ENTITY_TO_CLASS( restart_round, CRestartRoundEntity);


BEGIN_DATADESC( CRestartRoundEntity)

	DEFINE_INPUTFUNC( FIELD_VOID, "RestartRound", InputRestart ),

END_DATADESC();

void CRestartRoundEntity::InputRestart( inputdata_t &inputdata )
{
	//HL2MPRules()->CleanUpMap(); //Commented by R_Yell: Somehow this entity works with this omitted

	//spawn each player
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBaseEntity *plr = UTIL_PlayerByIndex( i );

		if ( plr )
		{
			plr->Spawn();
		} 
		else 
		{
			break;
		}
	} 

}